package com.example.spring_mysql.service.impl;

//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.spring_mysql.entity.User
import com.example.spring_mysql.entity.table.UserTableDef
import com.example.spring_mysql.mapper.UserMapper
import com.example.spring_mysql.service.IUserService
import com.mybatisflex.core.query.QueryWrapper
import com.mybatisflex.spring.service.impl.ServiceImpl
import org.springframework.stereotype.Service

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author hjw
 * @since 2025-06-11
 */
@Service
open class UserServiceImpl : ServiceImpl<UserMapper, User>(), IUserService {
    override fun selectByUsernameAndPsw(username: String, pws: String): List<User> {
        return this.mapper.selectByUsernameAndPsw(username, pws)
    }

    override fun getUserByName(username: String): User? {
        val wrapper: QueryWrapper = QueryWrapper.create()
            .where(UserTableDef.USER.USERNAME.eq("hjw"))
        return getOne(wrapper)
    }

    override fun getUsersBySelf(): List<User> {
        return this.mapper.getUsers()
    }
}
